﻿@model PagedList.IPagedList<Mantenimiento.Models.PLANTILLA>

@{
    ViewBag.Title = "Plantilla";
}

<h2>Plantilla</h2>
<script type="text/javascript">
        $(document).ready(function () {
 
            $.ajaxSetup({ cache: false });
           
            $(".confirmDialog").live("click", function (e) {
 
                var url = $(this).attr('href');
                
                $("#dialog-confirm").dialog({
                    title: 'Mensaje de Confirmación',
                    autoOpen: false,
                    resizable: false,
                    height: 170,
                    width: 350,
                    show: { effect: 'drop', direction: "up" },
                    modal: true,
                    draggable: true,
                    buttons: {
                        "OK": function () {
                            $(this).load(url);
                            window.location = "/Plantilla/Index";
                            window.location = "/Plantilla/Index";                                               
                        },
                        "Cancel": function () {
                            $(this).dialog("close");
 
                        }
                    }
                });
                $("#dialog-confirm").dialog("open");
                return false;
            });
 
        });  
    </script>

@using (Html.BeginForm())
{ 
    <div id="dialog-confirm" style="display: none">
        <p>
            <span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>
            ¿Está seguro de eliminar la plantilla?
        </p>
    </div>
    
    <p>
        Nombre de Plantilla: @Html.TextBox("buscaNombrePlantilla")
        <input type="submit" value="Buscar" />
        @Html.ActionLink("Nuevo", "Create", new {}, new { @class = "buttonClass"})
    </p> 

<p>
    Lista de plantillas de mantenimiento
</p>

<table>
    <tr>
        <th>
            @Html.ActionLink("Código", "Index", new { sortOrder = "PLANTILLAID", buscaNombrePlantilla = ViewBag.BuscaNombrePlantilla })
        </th>
        <th>
            @Html.ActionLink("Nombre de Plantilla", "Index", new { sortOrder = "DESCRIPCION", buscaNombrePlantilla = ViewBag.BuscaNombrePlantilla })
        </th>
        <th>Régimen
        </th>
        <th>Opciones</th>
    </tr>

    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.PLANTILLA_ID)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.DESCRIPCION)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.REGIMENDES)
            </td>
            <td>
                @*@Html.ActionLink("Detalles", "Details", new { id = item.PLANTILLA_ID }) |*@
                @Html.ActionLink("Modificar", "Edit", new { id = item.PLANTILLA_ID }) |
                @*@Html.ActionLink("Eliminar", "Delete", new { id = item.PLANTILLA_ID })*@
                @Html.ActionLink("Eliminar", "Delete", new { id = item.PLANTILLA_ID }, new { @class = "confirmDialog" })
            </td>
        </tr>
    }

</table>
<div style="margin-top:30px">
    Página @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) de @Model.PageCount
    &nbsp; 
    @if (Model.HasPreviousPage)
    { 
        @Html.ActionLink("<<", "Index", new
   {
       page = 1,
       sortOrder = ViewBag.CurrentSort,
       currentFilter = ViewBag.CurrentFilter,
       buscaNombrePlantilla = ViewBag.BuscaNombrePlantilla
   }, new { @class = "buttonClass" })

        @Html.Raw("&nbsp;"); 
        @Html.ActionLink("< ", "Index", new
   {
       page = Model.PageNumber - 1,
       sortOrder = ViewBag.CurrentSort,
       currentFilter = ViewBag.CurrentFilter,
       buscaNombrePlantilla = ViewBag.BuscaNombrePlantilla
   }, new { @class = "buttonClass" })
    }
    else
    { 
        @:<< 
        @Html.Raw("&nbsp;"); 
        @:<  
    }
    &nbsp; 
    @if (Model.HasNextPage)
    { 
        @Html.ActionLink(" >", "Index", new
   {
       page = Model.PageNumber + 1,
       sortOrder = ViewBag.CurrentSort,
       currentFilter = ViewBag.CurrentFilter,
       buscaNombrePlantilla = ViewBag.BuscaNombrePlantilla
   }, new { @class = "buttonClass" })

        @Html.Raw("&nbsp;"); 
        @Html.ActionLink(">>", "Index", new
   {
       page = Model.PageCount,
       sortOrder = ViewBag.CurrentSort,
       currentFilter = ViewBag.CurrentFilter,
       buscaNombrePlantilla = ViewBag.BuscaNombrePlantilla
   }, new { @class = "buttonClass" })
    }
    else
    { 
        @: > 
        @Html.Raw("&nbsp;") 
        @:>> 
    }
</div>
}

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
    @Scripts.Render("~/bundles/jqueryui")
}